package com.test.xshang.reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * @BelongsProject: simpleframework
 * @BelongsPackage: com.Xshang.reflect
 * @Author: xshang
 * @CreateTime: 2023-06-23  19:54
 * @Description: 通过反射获取构造方法并实例化对象
 * @Version: 1.0
 */
public class ConstructorCollector {

    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {

        Class<?> clazz = Class.forName("com.test.xshang.reflect.ReflectTarget");

        Constructor<?> constructors = clazz.getDeclaredConstructor(char.class);
        constructors.setAccessible(true);
        ReflectTarget reflectTarget = (ReflectTarget) constructors.newInstance('1');

    }
}
